package torres.item.interactive;

import torres.entity.Entity;
import torres.item.TakeableItem;

/**
 * @author Torres
 * An interaction that controls the mechanism for a locked door.
 */
@SuppressWarnings("serial")
public class Door implements Interaction {
	
	private TakeableItem key;
	
	/**
	 * Creates a new locked door that requires the specified item to be opened.
	 * @param key The item needed to unlock the door.
	 */
	public Door(TakeableItem key) {
		this.setKey(key);
	}
	
	/**
	 * Use this interaction on the specified entity.
	 * @param The Entity that is using this Interaction. 
	 */
	public void use(Entity e) {
		
		e.hasItem(this.getKey());
	}

	
	/**
	 * Get the Item needed to unlock this door.
	 * @return The Item needed to unlock this door.
	 */
	public TakeableItem getKey() {
		
		return this.key;
	}
	
	/**
	 * Set a new key Item for the door.
	 * @param key The new key Item for the door.
	 */
	private void setKey(TakeableItem key) {
		this.key = key;
	}
}
